package mozi.com.oneday.utils;

import android.util.Log;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import mozi.com.oneday.gson.User;

/**
 * Created by 执子一白 on 2017/5/22.
 */

public class Utility {
    private static final String TAG = "Utility";

    public static User handleWeatherResponse(String response){
        try {
           /* JSONObject jsonObject=new JSONObject(response);
            JSONArray jsonArray=jsonObject.getJSONArray("HeWeather");
            String userContent=jsonArray.getJSONObject(0).toString();
            return new Gson().fromJson(userContent,User.class);*/
            Gson gson=new Gson();
            User user=gson.fromJson(response,new TypeToken<User>(){}.getType());
            return user;
        } catch (Exception e) {
            e.printStackTrace();
            Log.d(TAG, "handleWeatherResponse: "+e.getMessage());
        }
        return null;
    }

}
